package com.okq.util.page;

import org.apache.commons.lang.StringUtils;

@SuppressWarnings("all")
public class QueryParameter {

	public static final String ASC = "asc";
	public static final String DESC = "desc";
	protected int pageNo = 1;
	protected int pageSize = 10;
	protected String orderBy = null;
	protected String order = "asc";
	protected boolean autoCount = false;

	public QueryParameter() {
	}

	public int getPageSize() {
		return this.pageSize;
	}

	public void setPageSize(int var1) {
		this.pageSize = var1;
	}

	public boolean isPageSizeSetted() {
		return this.pageSize > -1;
	}

	public int getPageNo() {
		return this.pageNo;
	}

	public void setPageNo(int var1) {
		this.pageNo = var1;
	}

	public int getFirst() {
		return this.pageNo >= 1 && this.pageSize >= 1 ? (this.pageNo - 1) * this.pageSize : -1;
	}

	public boolean isFirstSetted() {
		return this.pageNo > 0 && this.pageSize > 0;
	}

	public String getOrderBy() {
		return this.orderBy;
	}

	public void setOrderBy(String var1) {
		this.orderBy = var1;
	}

	public boolean isOrderBySetted() {
		return StringUtils.isNotBlank(this.orderBy);
	}

	public String getOrder() {
		return this.order;
	}

	public void setOrder(String var1) {
		if (!"asc".equalsIgnoreCase(var1) && !"desc".equalsIgnoreCase(var1)) {
			throw new IllegalArgumentException("order should be \'desc\' or \'asc\'");
		} else {
			this.order = var1.toLowerCase();
		}
	}

	public boolean isAutoCount() {
		return this.autoCount;
	}

	public void setAutoCount(boolean var1) {
		this.autoCount = var1;
	}
}
